////////////////////////////////////////////////////////////////////////////////
//
//  http://www.17nce.com
//  Copyright 2011-2012 
//  All Rights Reserved.
//
//  gtshao@sina.cn  2010-12-24
//
////////////////////////////////////////////////////////////////////////////////
package com.nce.model{
	import com.nce.ApplicationFacade;
	
	import flash.net.Responder;
	
	import mx.collections.ArrayCollection;
	
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	
	/**
	 * 
	 */
	public class LsnProxy extends CommonProxy {
		public static const NAME:String = "LsnProxy";
		private var gateway:String = "http://www.ncewx.com/gateway/lsn/";
		private var lesson:Array;
		private var termLessonsArr:Array;
		public function LsnProxy(data:Object=null)
		{
			var term1Str:String = "Lesson 1 Excuse me! 对不起!^Lesson 3 Sorry,sir. 对不起，先生。^Lesson 5 Nice to meet you. 很高兴见到你。^Lesson 7 Are you a teacher? 你是教师吗？^Lesson 9 How are you today? 你今天好吗？^Lesson 11 Is this your shirt? 这是你的衬衫吗？^Lesson 13 A new dress 一件新连衣裙^Lesson 15 Your passports,please. 请出示你们的护照。^Lesson 17 How do you do? 你好！^Lesson 19 Tired and thirsty 又累又渴^Lesson 21 Which book? 哪一本书？^Lesson 23 Which glasses? 哪几只杯子？^Lesson 25 Mrs.Smith's kitchen 史密斯太太的厨房^Lesson 27 Mrs.Smith's living room 史密斯太太的客厅^Lesson 29 Come in,Amy. 进来，艾米。^Lesson 31 Where's Sally? 萨莉在哪里？^Lesson 33 A fine day 晴天^Lesson 35 Our village 我们的村庄^Lesson 37 Making a bokcase 做书架^Lesson 39 Don't drop it! 别摔了！^Lesson 41 Penny's bag 彭妮的提包^Lesson 43 Hurry up! 快点！^Lesson 45 The boss's letter 老板的信^Lesson 47 A cup of coffee 一杯咖啡^Lesson 49 At the butcher's 在肉店^Lesson 51 A plesant climate 宜人的气候^Lesson 53 Am interesting climate 有趣的气候^Lesson 55 The Sawyer family 索耶一家人^Lesson 57 Am unusual day 很不平常的一天^Lesson 59 Is that all? 就这些吗？^Lesson 61 A bad cold 重感冒^Lesson 63 Thand you,doctor. 谢谢你，医生。^Lesson 65 Not a baby 不是一个孩子^Lesson 67 The weekend 周末^Lesson 69 The car race 汽车比赛^Lesson 71 He's awful! 他讨厌透了！^Lesson 73 The way to King Street 到国王街的走法^Lesson 75 Uncomfortable shoes 不舒适的鞋子^Lesson 77 Terrible toothache 要命的牙痛^Lesson 79 Carol's shopping list 卡罗尔的购物单^Lesson 81 Roast beef and potatoes 烤牛肉和土豆^Lesson 83 Going on holiday 度假^Lesson 85 Paris in the spring 巴黎之春^Lesson 87 A car crash 车祸^Lesson 89 For sale 待售^Lesson 91 Poor Ian! 可怜的伊恩！^Lesson 93 Our new neighbour 我们的新邻居^Lesson 95 Tickets,please. 请把车票拿出来。^Lesson 97 A small bluc case 一只蓝色的小箱子^Lesson 99 Ow! 啊哟！^Lesson 101 A card from Jimmy 吉米的明信片^Lesson 103 The French test 法语考试^Lesson 105 Full of mistakes 错误百出^Lesson 107 It's too small. 太小了。^Lesson 109 A good idea 好主意^Lesson 111 The most expenxive model 最昂贵的型号？^Lesson 113 Small changes 零钱^Lesson 115 Knock,knock! 敲敲门！^Lesson 117 Tommy's breakfast 汤米的早餐^Lesson 119 A true story 一个真实的故事^Lesson 121 The man in a hat 戴帽子的男士^Lesson 123 A trip to Australia 澳大利亚之行^Lesson 125 Tea for two 两个人一起喝茶^Lesson 127 A famous actress 著名的女演员^Lesson 129 Seventy miles an hour 时速70英里^Lesson 131 Don't be so sure! 别那么肯定！^Lesson 133 Sensational news! 爆炸性新闻！^Lesson 135 The latest report 最新消息^Lesson 137 Apleasant dream 美好的梦^Lesson 139 Is that you,John? 是你吗，约翰？^Lesson 141 Sally's first train ride 萨莉第一次乘火车旅行^Lesson 143 A walk throughthe woods 林中散步";
			var term2Str:String = "Lesson 1 A private conversation 私人谈话^Lesson 2 Breakfast or lunch? 早餐还是午餐？^Lesson 3 Please send me a card 请给我寄一张明信片^Lesson 4 An exciting trip 激动人心的旅行^Lesson 5 No wrong numbers 无错号之虞^Lesson 6 Percy Buttons 珀西·巴顿斯^Lesson 7 Too late 为时太晚^Lesson 8 The best and the worst 最好的和最差的^Lesson 9 A cold welcome 冷遇^Lesson 10 Not for jazz 不适于演奏爵士乐^Lesson 11 One good turn deserves another 礼尚往来^Lesson 12 Gooddbye and good luck 再见，一路顺风^Lesson 13 The Greenwood Boys 绿林少年^Lesson 14 Do you speak English? 你会讲英语吗？^Lesson 15 Good news 佳音^Lesson 16 A polite request 彬彬有礼的要求^Lesson 17 Always young 青春常驻^Lesson 18 He often does this! 他经常干这种事！^Lesson 19 Sold out 票已售完^Lesson 20 One man in a boat 独坐孤舟^Lesson 21 Mad or not? 是不是疯了！^Lesson 22 A glass envelope 玻璃信封^Lesson 23 A new house 新居^Lesson 24 It could be worse 不幸中之万幸^Lesson 25 Do the English speak English? 英国人讲的是英语吗？^Lesson 26 The best art critics 最佳美术评论家^Lesson 27 A wet night 雨夜^Lesson 28 No parking 禁止停车^Lesson 29 Taxi! 出租汽车！^Lesson 30 Football or polo? 足球还是水球？^Lesson 31 Success story 成功者的故事^Lesson 32 Shopping made easy 购物变得很方便^Lesson 33 Out of the darkness 冲出黑暗^Lesson 34 Quick work 破案＂神速＂^Lesson 35 Stop thief! 捉贼！^Lesson 36 Across the Channel 横渡海峡^Lesson 37 The Olympic Games 奥林匹克运动会^Lesson 38 Everything except the weather 惟独没有考虑到天气^Lesson 39 Am I all right? 我是否痊愈？^Lesson 40 Food and talk 进餐与交谈^Lesson 41 Do you call that a hat? 你把那个叫帽子吗？^Lesson 42 Not very musical 并非很懂音乐^Lesson 43 Over the South Pole 飞越南极^Lesson 44 Through the forest 穿过森林^Lesson 45 A clear conscitnce 问心无愧^Lesson 46 Expensive and uncomfortable 既昂贵又受罪^Lesson 47 A thirsty ghost 嗜酒的鬼魂^Lesson 48 Did yor want to tell me something? 你想对我说什么吗？^Lesson 49 The end of a dream 美梦告终^Lesson 50 Taken for a ride 乘车兜风^Lesson 51 Reward for virtue 对美德的奖赏^Lesson 52 A pretty carpet 漂亮的地毯^Lesson 53 Hot snake 触电的蛇^Lesson 54 Sticky fingers 粘糊的手指^Lesson 55 Not a gold mine 并非金矿^Lesson 56 Faster than sound! 比声音还快！^Lesson 57 Can I help you,madam? 你要买什么，夫人？^Lesson 58 A blessing in disguise? 是因祸得福吗？^Lesson 59 In or out? 进来还是出去？^Lesson 60 The future 卜算未来^Lesson 61 Trouble with the Hubble 哈勃望远镜的困境^Lesson 62 After the fir 大火之后^Lesson 63 She was not amused 她并不觉得好笑^Lesson 64 The Channel Tunnel 海峡隧道^Lesson 65 Jumbo versrs the police 小象对警察^Lesson 66 Sweet as honey! 像蜜一样甜^Lesson 67 Volcanoes 火山^Lesson 68 Persistent 纠缠不休^Lesson 69 But noot murder! 并非谋杀！^Lesson 70 Red for danger 危险的红色^Lesson 71 A famous clock 一个著名的大钟^Lesson 72 A car called Bluebird ＂蓝鸟＂汽车^Lesson 73 The record-holder 纪录保持者^Lesson 74 Out of the limelight 舞台之外^Lesson 75 SOS 呼救信号^Lesson 76 April Fools'Day 愚人节^Lesson 77 A successful operation 一例成功的手术^Lesson 78 The last one? 最后一枝吗？^Lesson 79 By air 乘飞机^Lesson 80 The Crystal Palace 水晶宫^Lesson 81 Escape 脱逃^Lesson 82 Monster or fish? 是妖还是鱼？^Lesson 83 After the elections 大选之后^Lesson 84 On strike 罢工^Lesson 85 Never too old to learn 活到老学到老^Lesson 86 Out of control 失控^Lesson 87 A operfect alibi 极好的不在犯罪现场的证据^Lesson 88 Trapped in a mine 困在矿井里^Lesson 89 A slip of the tongue 口误^Lesson 90 What's for supper? 晚餐吃什么？^Lesson 91 Three men in a basket 三人同篮^Lesson 92 Asking for trouble 自找麻烦^Lesson 93 A noble gift 崇高的礼物^Lesson 94 Future champions 未来的冠军^Lesson 95 A fantasy 纯属虚构^Lesson 96 The dead return 亡灵返乡";
			var term3Str:String ="Lesson 1 A puma at large 逃遁的美洲狮^Lesson 2 Thirteen equals one 十三等于一^Lesson 3 An unddnown goddess 无名女神^Lesson 4 The double life of Alfred Bloggs 阿尔弗雷德·布洛格斯的双重生活^Lesson 5 The facts 确切数字^Lesson 6 Smash-and-grab 砸橱窗抢劫^Lesson 7 Mutilated ladies 残钞鉴别组^Lesson 8 A famous monastery 著名的修道院^Lesson 9 Flying cats 飞猫^Lesson 10 The loss of the Titanic ＂泰坦尼克＂号的沉没^Lesson 11 Not guilty 无罪^Lesson 12 Life on a desert island 荒岛生活^Lesson 13 'It's only me' ＂是我，别害怕＂^Lesson 14 A noble gangster 贵族歹徒^Lesson 15 Fifty pence worth of trouble 五十便士的麻烦^Lesson 16 Mary had a little lamb 玛丽有一头小羔羊^Lesson 17 The longest suspension bridge in the world 世界上最长的吊桥^Lesson 18 Electric currents in modern art 现代艺术中的电流^Lesson 19 A very dear cat 一只贵重的宝贝猫^Lesson 20 Pioneer pilots 飞行员的先驱^Lesson 21 Daniel Mendoza 丹尼尔·门多萨^Lesson 22 By heart 熟记台词^Lesson 23 One man's meat is another man's poison 各有所爱^Lesson 24 A skeleton in the cupboard 家丑＂^Lesson 25 The＂ Cutty Sark 卡蒂萨克号帆船^Lesson 26 Wanted:a large biscuit tin 征购大饼干筒^Lesson 27 Nothing to sell and nothing to buy 不卖也不买^Lesson 28 Five pounds too dear 五镑也太贵^Lesson 29 Funny or not? 是否可笑？^Lesson 30 The death of a ghost 幽灵之死^Lesson 31 A lovable eccentric 可爱的怪人^Lesson 32 A lost ship 一艘沉船^Lesson 33 A day to remenber 难忘的一天^Lesson 34 A happy discovery 幸运的发现^Lesson 35 Justice was done 伸张正义^Lesson 36 A chance in a million 百万分之一的机遇^Lesson 37 The Westhaven Express 开往威斯特海温的快车^Lesson 38 The first calendar 最早的日历^Lesson 39 Nothing to worry about 不必担心^Lesson 40 Who's who 真假难辨^Lesson 41 Illusions of pastoral peace 宁静田园生活的遐想^Lesson 42 Modern cavemen 现代洞穴人^Lesson 43 Fully insured 全保险^Lesson 44 Speed and comfort 又快捷又舒适^Lesson 45 The power of the press 新闻报道的威力^Lesson 46 Do it yourself 自己动手^Lesson 47 Too high a price? 代价太高？^Lesson 48 The silent village 沉默的村庄^Lesson 49 The ideal servant 理想的仆人^Lesson 50 Mew Year resolutions 新年的决心^Lesson 51 Predicting the future 预测未来^Lesson 52 Mud is mud 实事求是^Lesson 53 In the public interest 为了公众的利益^Lesson 54 Instinct or cleverness? 是本能还是机智？^Lesson 55 From the earth:Greetings 来自地球的问候^Lesson 56 Our neighbour,the river 河流，我们的邻居^Lesson 57 Back in the old country 重返故里^Lesson 58 A spot of bother 一点儿小麻烦^Lesson 59 Collecting 收藏^Lesson 60 Too early and too late 太早和太晚";
			var term4Str:String ="Lesson 1 Finding fossil man 发现化石人^Lesson 2 Spare that spider 不要伤害蜘蛛^Lesson 3 Matterhorn man 马特霍恩山区人^Lesson 4 Seeing hands 能看见东西的手^Lesson 5 Youth 青年^Lesson 6 The sporting spirit 体育的精神^Lesson 7 Bats 蝙蝠^Lesson 8 Trading standards 贸易标准^Lesson 9 Royal espionage 王室谍报活动^Lesson 10 Silicon Valley 硅谷^Lesson 11 How to grow old 如何安度晚年^Lesson 12 Banks and their customers 银行和顾客^Lesson 13 The search for oil 探寻石油^Lesson 14 The Butterfly Effect 蝴蝶效应^Lesson 15 Secrecy in industry 工业中的秘密^Lesson 16 The modern city 现代城市^Lesson 17 A man-made disease 人为的疾病 ^Lesson 18 Porpoises 海豚^Lesson 19 The stuff of dreams 话说梦的本质^Lesson 20 Snake poison 蛇毒^Lesson 21 William S.Hart and the early 'Western'film 威廉·S·哈特和早期＂西部＂影片^Lesson 22 Knowledge and progress 知识和进步^Lesson 23 Bird flight 鸟的飞行方法^Lesson 24 Beauty 美^Lesson 25 Non-auditory effects of noise 噪音的非听觉效应^Lesson 26 The past life of the earth 地球上昔日生命^Lesson 27 The Vasa 瓦萨号^Lesson 28 Patients and doctors 病人与医生^Lesson 29 The hovercraft 气垫船^Lesson 30 Exploring the sea-floor 海底勘探^Lesson 31 The sculptor speaks 雕塑家的语言^Lesson 32 Galileo reborn 伽利略的复生^Lesson 33 Education 教育^Lesson 34 Adolescence 青春期^Lesson 35 Space odyssey 太空探索^Lesson 36 The cost of government 政府的开支^Lesson 37 The process of ageing 衰老过程^Lesson 38 Water and the traveller 水和旅行者^Lesson 39 What every writer wants 作家之所需^Lesson 40 Waves 海浪^Lesson 41 Training elephants 训练大象^Lesson 42 Recording an earthquake 记录地震^Lesson 43 Are there strangers in space? 宇宙中有外星人吗？^Lesson 44 Patterns of culture 文化的模式^Lesson 45 Of men and galaxies 人和星系^Lesson 46 Hobbies 业余爱好^Lesson 47 The great escape 大逃亡^Lesson 48 Planning a share portfolio 规划股份投资";
			
			termLessonsArr = new Array();
			var termArr:ArrayCollection = new ArrayCollection();
			termArr.source = term1Str.split("^");
			termLessonsArr.push(termArr);
			
			termArr = new ArrayCollection();
			termArr.source = term2Str.split("^");
			termLessonsArr.push(termArr);
			
			termArr = new ArrayCollection();
			termArr.source = term3Str.split("^");
			termLessonsArr.push(termArr);
			
			termArr = new ArrayCollection();
			termArr.source = term4Str.split("^");
			termLessonsArr.push(termArr);
			
			super(gateway,NAME, data);
			
		}
		
		public function getLessons(term:int){
			trace("getLessons"+term);
			call("LsnAction.getLessons",new Responder(onGetLessons,onFault),term);
		}
		
		public function get lsn():Array
		{
			return lesson;
		}
		
		public function setSentenceUsEtime(id:int,ms:int):void{
			call("LsnAction.setSentenceUsEtime",new Responder(onSetSentenceEtime,onFault),id,ms);
		}
		
		public function setSentenceUsStime(id:int,ms:int):void{
			call("LsnAction.setSentenceUsStime",new Responder(onSetSentenceStime,onFault),id,ms);
		}
		
		public function setSentenceEtime(id:int,ms:int):void{
			call("LsnAction.setSentenceEtime",new Responder(onSetSentenceEtime,onFault),id,ms);
		}
		
		public function setSentenceStime(id:int,ms:int):void{
			call("LsnAction.setSentenceStime",new Responder(onSetSentenceStime,onFault),id,ms);
		}
		
		public function merge(idPre:int,idCrt:int):void{
			call("LsnAction.merge",new Responder(onNothing,onFault),idPre,idCrt);
		}
		
		public function decreaseIdx(id:int,idx:int):void{
			call("LsnAction.decreaseIdx",new Responder(onNothing,onFault),id,idx);
		}
		
		public function getLsn(lesson:int,term:int):void{
			if(term==1){
				lesson = lesson * 2 -1;
			}
			call("LsnAction.getLsn",new Responder(onGetLsn,onFault),lesson,term);
		}
		
		private function onNothing(res:Object):void{
			
		}
		
		private function onSetSentenceEtime(res:Object):void{
			
		}
		
		private function onSetSentenceStime(res:Object):void{
			
		}
	
		private function onGetLessons(res:Object):void{
			
			var lessons:Array = res as Array;
			sendNotification(ApplicationFacade.GET_LESSONS,lessons);
			
		}
		
		private function onGetLsn(res:Object):void{
			
			lesson = res as Array;
			sendNotification(ApplicationFacade.CHANGE_LESSON,lesson);
//			for (var i:int = 0; i < lsn.length; i++) {
//				var obj:Object = lsn[i];
//				trace(obj.en_text);
//				
//			}
		}
		
		
	}
}